package ablaufsichtstelle.zugeditor;

import java.awt.Component;

import javax.swing.JComboBox;
import javax.swing.JTable;
import javax.swing.table.TableCellRenderer;

/**
 * 
 * @author Nilientes
 *
 */
public class JComboBoxRenderer extends JComboBox implements TableCellRenderer {

	/**
	 * 
	 * @param items
	 */
	public JComboBoxRenderer(String[] items) {
        super(items);
    }

	public Component getTableCellRendererComponent(JTable table, Object value,
            boolean isSelected, boolean hasFocus, int row, int column)
	{
		if (isSelected) {
            setForeground(table.getSelectionForeground());
            super.setBackground(table.getSelectionBackground());
        } else {
            setForeground(table.getForeground());
            setBackground(table.getBackground());
        }

        // Select the current value
        setSelectedItem(value);
        return this;

	}

}
